package com.example.mvc.context;

import com.example.common.utils.Statistics;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.HttpRequestHandler;

import java.io.IOException;

@Slf4j
@Component("/myHttpRequestHandler")
public class MyHttpRequestHandler implements HttpRequestHandler {

    @Override
    public void handleRequest(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response)
            throws ServletException, IOException {
        Statistics.logInfo(log, "handleRequest", request);
        response.getWriter().write("hello, http request handler");
    }
}
